#include "headers/Builder.h"
#include "headers/TextBuilder.h"
#include "headers/HTMLBuilder.h"
#include "headers/Director.h"
#include <iostream>
#include <cstring>

void usage()
{
    std::cout << "Usage: exe_builder [h|t]" << std::endl;
}
int main (int argc, char* argv[])
{
    if(argc < 1)
    {
        std::cout << "no argument" << std::endl;
        return -1;
    }

    /* select target concrete-builder */
    // TextBuilder is current concrete-builder
    std::shared_ptr<TextBuilder> textBuilder = std::make_shared<TextBuilder>();
    Director dr(textBuilder);
    std::string res; 

    /* select target concrete-builder */
    // HTMLbuilder is current concrete-builder
    std::shared_ptr<HTMLBuilder> htmlbuilder = std::make_shared<HTMLBuilder>();
    Director dr2(htmlbuilder);    
    std::string filename;

    /* select what type product need to be test at currente round */
    // strcmp() returns 0 if matches
    if(!strcmp(argv[1], "t"))    
    {
        dr.construct();
        res = textBuilder->toString();
        std::cout << res << std::endl;
    }
    else if (!strcmp(argv[1], "h"))
    {
        dr2.construct();        
        filename = htmlbuilder->getFileName();            
        std::cout << filename << " documents generate finished." << std::endl;
    }
    else 
        usage();
}